import Vue from 'vue'
import VueRouter from 'vue-router'
// 匹配下面的路由懒加载
// const login=()=>import('@/views/login')


Vue.use(VueRouter)

const routes = [
  {
    path:'/login',
    name:'login',
    // 路由懒加载
    component:()=>import('@/views/login/')
  },
  {
    path:'/',
    component:()=>import('@/views/layout/'),
    children:[
      {
        path:'',//默认子路由
        name:'home',
        component:()=>import('@/views/home/')
      },
      {
        path:'/qa',//默认子路由
        name:'qa',
        component:()=>import('@/views/qa/')
      },
      {
        path:'/video',//默认子路由
        name:'video',
        component:()=>import('@/views/video/')
      },
      {
        path:'/my',//默认子路由
        name:'my',
        component:()=>import('@/views/my/')
      },
    ]
  },
  {
    path:'/search',//默认子路由
    name:'search',
    component:()=>import('@/views/search/')
  },
  {
    path:'/article/:articleId',
    name:'article',
    component:()=>import('@/views/article/'),
    // 将动态路由参数映射到组件的props中，无论是访问还是维护都很方便
    props:true
  },
  {
    path:'/user/profile',
    name:'user-profile',
    component:()=>import('@/views/user-profile/')
  },
  {
    path:'/user/chat',
    name:'user-chat',
    component:()=>import('@/views/user-chat/')
  }
]

const router = new VueRouter({
  routes
})

export default router
